//
//  MGSection.h
//  Express
//
//  Created by lhongl on 2025/9/25.
//  Copyright © 2025 QM. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@class MGTableViewManage,MGItem;
NS_ASSUME_NONNULL_BEGIN

typedef void (^SectionForHeaderView)(__kindof UIView *headerView ,NSInteger section);

typedef void (^SectionForFooterView)(__kindof UIView *footerView ,NSInteger section);

typedef CGFloat (^SectionForHeaderHeight)(NSInteger section);

typedef CGFloat (^SectionForFooterHeight)(NSInteger section);

typedef NSString *_Nullable(^SectionForHeaderTitle)(NSInteger section);

typedef NSString * _Nullable (^SectionForFooterTitle)(NSInteger section);

typedef UIView * _Nullable (^SectionForCustomHeaderView)(NSInteger section);

typedef UIView * _Nullable (^SectionForCustomFooterView)(NSInteger section);

@interface MGSection : NSObject

@property (nonatomic, weak) MGTableViewManage *tableManage;

/// 下标
@property (nonatomic, assign, readonly) NSInteger section;

/// 数据
@property (nonatomic, strong, readonly) NSArray <MGItem *> *itemList;

/// HeaderIdent
@property (nonatomic, copy, readonly) NSString *headerIdentifier;

/// FooterIdent
@property (nonatomic, copy, readonly) NSString *footerIdentifier;

///header 高
@property (nonatomic, copy) SectionForHeaderHeight heightForHeader;

///footer 高
@property (nonatomic, copy) SectionForFooterHeight heightForFooter;

///header标题
@property (nonatomic, copy) SectionForHeaderTitle titleForHeader;

///footer 标题
@property (nonatomic, copy) SectionForFooterTitle titleForFooter;

/// 自定义headerView
@property (nonatomic, copy) SectionForCustomHeaderView customViewForHeader;

/// 自定义footerView
@property (nonatomic, copy) SectionForCustomFooterView customViewForFooter;

/*
  权限说明:
  headerView: customViewForHeader > viewForHeader[系统系统]
  footerView: customViewForFooter > viewForFooter[系统系统]
 */

+ (instancetype)section;

// 注册
- (void)dequeueReusableHeaderClass:(nullable Class)headerClass footerClass:(nullable Class)footerClass;


#pragma mark 系统方法 【使用必须注册】
@property (nonatomic, copy) SectionForHeaderView viewForHeader;

@property (nonatomic, copy) SectionForFooterView viewForFooter;


#pragma mark - 添加item
- (void)addItem:(MGItem *)item;
- (void)addItemWithItems:(NSArray <MGItem *>*)items;

#pragma mark 插入
- (void)insertItem:(MGItem *)item atIndex:(NSUInteger)idx;
- (void)insertItems:(NSArray <MGItem *> *)items atIndex:(NSUInteger)idx;

#pragma mark - 删除item
- (void)removeAllItem;
- (void)removeItemWithIndex:(NSInteger)index;
- (void)removeItemWithItems:(NSArray <MGItem *>*)items;
- (void)removeItem:(MGItem *)item;


#pragma mark 替换item
- (void)replaceItemWithIndex:(NSUInteger)index item:(MGItem *)item;




@end

NS_ASSUME_NONNULL_END
